﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace TemplateDemo
{
    public class GlobalException : IExceptionFilter
    {
        private ILogger<GlobalException> logger;
        public GlobalException(ILogger<GlobalException> _logger)
        {
            logger = _logger;
        }
        public void OnException(ExceptionContext context)
        {
            logger.LogError(context.HttpContext.TraceIdentifier, context.Exception, context.Exception.ToString());
        }
    }
}
